<?php
use app\common\config\autoreply_config;
use app\common\helper\index_msg_helper;
use app\common\helper\appmsg_helper;
?>

{include file="../app/common/admin/lib/header.html"  title="自动回复"}
{include file="../app/autoreply/view/lib/top_menu.html"}

<div class="rlbox">
  <p class="tabnav">当前的设置为：{:autoreply_config::$autoreply_content_type[$content_info.content_type]}，
  <a class="color" style="color:#23a18b;" href='{:url("/autoreply/add/$autoreply_type", ["content_type"=>$content_info.content_type])}'>点击去修改</a>
  <a class="color js_cancelReplyBtn" style="color:#ff3333; margin-left:3px;" data-type="{$autoreply_type}" href="javascript:void(0);">取消此回复</a>
  </p>

  {if $content_info.content_type == 0}
  {include file="../app/autoreply/view/lib/index_msg_list.html"}

  {elseif $content_info.content_type == 1 /}
  <div class="txtwrap">
    <div class="txtfill js_replyContent" style="background:#f9f9f9; color:#aaa; border:none; height:auto; min-height:156px;">{:htmlspecialchars_decode($content_info.content)}</div>
  </div>
  {elseif $content_info.content_type == 2 /}
  {$list = appmsg_helper::get_list(['type'=>1, 'select_id' => $content_info.content, 'id'=>$content_info.content])}
  {include file="../app/appmsg/view/lib/select_single_list.html"}
  {elseif $content_info.content_type == 3 /}
  {$list = appmsg_helper::get_list(['type'=>2, 'select_id' => $content_info.content, 'id'=>$content_info.content])}
  {include file="../app/appmsg/view/lib/select_multi_list.html"}
  {/if}
</div>
<script type="text/javascript">
$(function(){
  // 取消回复
  $(".js_cancelReplyBtn").click(function(e){
    e.preventDefault();
    
    var thisObj = $(this);
    var type = thisObj.attr('data-type');
    
    if (type < 1) {
      return '请选择要取消的回复类型';
    }
    
    if (thisObj.attr('is-post') == 1) {
      return false;
    }
    thisObj.attr('is-post', 1);
    var postData = { 'type':type };
    
    showConfirm('您确定要取消此回复吗?', 1, function(){
      $.post(siteUrl+'/autoreply/admin/cancel_reply', postData, function(json){
        if (json.info != 'ok') {
          thisObj.attr('is-post', 0);
          showMsg(json.info);
          return false;
        }
        
        location.reload();
      }, 'json').error(function(){
        showMsg('网络不稳定，请稍后再试');
        thisObj.attr('is-post', 0);
      });
    }, function(){
      thisObj.attr('is-post', 0);
    });
  });
});
</script>
{include file="../app/common/admin/lib/footer.html"}